package org.blogspot.t0yv0.marcalog.model

import javax.jdo.annotations._
import org.blogspot.t0yv0.marcalog.util._

@PersistenceCapable(identityType = IdentityType.APPLICATION)
class Person(theName: String) extends Entity {

  @PrimaryKey
  @Persistent
  override var id : String =
    theName.replaceAll("(\\s|[.,!:;])+$", "")

  theName match {
    case null => assert(false, "Person: name cannot be null.")
    case ""   => assert(false, "Person: name cannot be empty.")
    case _    => {}
  }

  @Persistent
  var key = Util.getFirstLetter(theName).toInt;

}
